package com.coscon.service.patternCommon.impl.video;

import com.coscon.model.IrcaCmd;
import com.coscon.service.patternCommon.ICommand;
import lombok.extern.slf4j.Slf4j;

import javax.websocket.Session;
import java.awt.*;
import java.awt.event.KeyEvent;

/**
 * 播放器音量+
 */
@Slf4j
public class PlayerVolumeAddCmdImpl implements ICommand {

    private Robot rb;

    public PlayerVolumeAddCmdImpl(Robot rb){
        this.rb = rb;
    }

    @Override
    public Boolean executeByMac(IrcaCmd cmd, Session session) {
        switch(cmd.getSoftType()){
            case "MAC_XUNLEI" :
            {
                rb.keyPress(KeyEvent.VK_UP);
                rb.delay(10);
                rb.keyRelease(KeyEvent.VK_UP);
            }
            //语句
            break; //可选
            case "MAC_VLC" :
            default:
            {
                rb.keyPress(KeyEvent.VK_META);
                rb.keyPress(KeyEvent.VK_UP);
                rb.delay(10);
                rb.keyRelease(KeyEvent.VK_META);
                rb.keyRelease(KeyEvent.VK_UP);
            }
        }
        return true;
    }

    @Override
    public Boolean executeByWin(IrcaCmd cmd, Session session) {
        rb.keyPress(KeyEvent.VK_UP);
        rb.delay(10);
        rb.keyRelease(KeyEvent.VK_UP);
        return true;
    }

    @Override
    public Boolean executeByLinux(IrcaCmd cmd, Session session) {
        return true;
    }

}
